package org.shoukaiseki.tencent.live.config;

import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.live.v20180801.LiveClient;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.inject.Named;

/**
 *
 **/
@Component
@EnableConfigurationProperties({TencentLiveCoreProperties.class})
public class TencentLiveCoreAutoConfig {

    @Resource
    TencentLiveCoreProperties tencentLiveCoreProperties;

    @Bean("liveCredential")
    public Credential liveCredential(){
        return new Credential(tencentLiveCoreProperties.getSecretId(), tencentLiveCoreProperties.getSecretKey());
    }


    @Bean
    public LiveClient liveClient(@Named("liveCredential") final Credential liveCredential){
        return new LiveClient(liveCredential, tencentLiveCoreProperties.getRegion());
    }

}
